home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Connector for iCat Commerce Online / data1.cab / Program_Executable_Files / iCat.jar / iCat / iCatCart.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-13  |  4.8 KB  |  141 lines

  1. package iCat;
  2.  
  3. import com.netobjects.nfc.api.CStringArray;
  4. import com.netobjects.nfc.api.ComponentApp;
  5. import com.netobjects.nfc.api.DAssetManager;
  6. import com.netobjects.nfc.api.DDrawPicture;
  7. import com.netobjects.nfc.api.DFile;
  8. import com.netobjects.nfc.api.DImage;
  9. import com.netobjects.nfc.api.DLayout;
  10. import com.netobjects.nfc.api.DMessageBox;
  11. import com.netobjects.nfc.api.DRect;
  12. import com.netobjects.nfc.api.DSite;
  13. import com.netobjects.nfc.api.DSize;
  14. import com.netobjects.nfc.api.IDInspector;
  15. import java.net.URLEncoder;
  16.  
  17. public class iCatCart extends ComponentApp {
  18.    String strImageFile = "";
  19.    String strReturnURL = "";
  20.    String strReturnURLEncoded = "";
  21.    int Image;
  22.    DDrawPicture cdp;
  23.    String codebase = "";
  24.    DAssetManager assetMan;
  25.  
  26.    public void onCopy() {
  27.       this.assetMan.CopyAsset(this.Image);
  28.    }
  29.  
  30.    protected void finalize() {
  31.       this.assetMan.RemoveAsset(this.Image);
  32.       this.strImageFile = null;
  33.       this.strReturnURL = null;
  34.       this.strReturnURLEncoded = null;
  35.       this.cdp = null;
  36.       this.codebase = null;
  37.       this.assetMan = null;
  38.    }
  39.  
  40.    public void onUnInstall(DAssetManager var1) {
  41.    }
  42.  
  43.    public String onInstall(DAssetManager var1, String var2) {
  44.       this.assetMan = var1;
  45.       this.codebase = var2;
  46.       this.strImageFile = this.codebase + "\\iCatCart.gif";
  47.       return "iCat Shopping Cart";
  48.    }
  49.  
  50.    public void onInspect(CStringArray var1, CStringArray var2) {
  51.       var1.Set("Return URL");
  52.       var2.Set("String");
  53.       var1.Set("Image");
  54.       var2.Set("Image");
  55.    }
  56.  
  57.    public String PropertyListener(String var1, String var2, int var3, int var4, IDInspector var5) {
  58.       if (var3 == 1) {
  59.          if (var1.compareTo("Return URL") == 0) {
  60.             return this.strReturnURL;
  61.          }
  62.  
  63.          if (var1.compareTo("Image") == 0) {
  64.             return Integer.toString(this.Image);
  65.          }
  66.       } else {
  67.          if (var1.compareTo("Return URL") == 0) {
  68.             this.strReturnURL = var2;
  69.             this.strReturnURLEncoded = URLEncoder.encode(var2);
  70.          } else if (var1.compareTo("Image") == 0) {
  71.             this.assetMan.RemoveAsset(this.Image);
  72.             this.Image = Integer.parseInt(var2, 10);
  73.             this.strImageFile = this.assetMan.GetAssetLocation(this.Image, 1, 1);
  74.             DImage var6 = new DImage();
  75.             var6.setImageFile(this.strImageFile);
  76.             DSize var7 = var6.getSize();
  77.             this.cdp.SetSize(var7.getWidth(), var7.getHeight());
  78.             this.cdp.setImageFile(this.assetMan.GetAssetLocation(this.Image, -1, 1));
  79.          }
  80.  
  81.          this.cdp.Invalidate(true);
  82.       }
  83.  
  84.       if (var5 != null) {
  85.          var5.OnPropertyChanged(-1);
  86.       }
  87.  
  88.       return "";
  89.    }
  90.  
  91.    public void onDrop(DLayout var1, DRect var2, int var3) {
  92.       if (var3 == 1) {
  93.          this.cdp = new DDrawPicture();
  94.          this.cdp.SetPositionRect(var2.getLeft(), var2.getTop(), var2.getRight(), var2.getBottom());
  95.          this.cdp.SetStyle(1, 1);
  96.          this.cdp.setStretch(2);
  97.          this.cdp.setUsePictureText(false);
  98.          DImage var4 = new DImage();
  99.          var4.setImageFile(this.strImageFile);
  100.          DSize var5 = var4.getSize();
  101.          this.cdp.SetSize(var5.getWidth(), var5.getHeight());
  102.          this.cdp.setImageFile(this.strImageFile);
  103.          var1.AddObject(this.cdp);
  104.       }
  105.    }
  106.  
  107.    public void onPublish(DAssetManager var1, int var2) {
  108.       String var4 = this.readiCatFile();
  109.       String var3 = "<A HREF=\"" + var4 + "/index.icl?execute=plugins--cart_display.icl";
  110.       if (this.strReturnURL.length() != 0) {
  111.          var3 = var3 + "&srcdoc=" + this.strReturnURLEncoded;
  112.       }
  113.  
  114.       var3 = var3 + "\" target=\"_top\" >";
  115.       this.cdp.setAltTag("View your shopping cart.");
  116.       this.cdp.setHTMLBefore(var3);
  117.       this.cdp.setHTMLAfter("</A>");
  118.    }
  119.  
  120.    public String readiCatFile() {
  121.       DSite var1 = new DSite();
  122.       String var2 = var1.getName();
  123.       String var3 = "";
  124.       DFile var4 = new DFile();
  125.       if (var4.Open(this.codebase + "iCatInfo\\" + var2 + ".txt", 0)) {
  126.          var3 = var4.ReadString(1000);
  127.          var4.Close();
  128.       } else {
  129.          DMessageBox var5 = new DMessageBox();
  130.          var5.Warning("The iCatCart component requires that you also use\r\nthe iCatBuilt or iCatAffiliate component on your site.\r\n\r\nPlease add one of these components to your site and republish.\r\n");
  131.       }
  132.  
  133.       return var3;
  134.    }
  135.  
  136.    private void debug(String var1) {
  137.       DMessageBox var2 = new DMessageBox();
  138.       var2.Warning(var1 + "\r\n");
  139.    }
  140. }
  141.